<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.gxgyl.com All rights reserved.

// +----------------------------------------------------------------------
// | Author: Liuyu
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\common\model\shiyao;

use cores\BaseModel;

/**
 * 模型
 * Class
 * @package app\common\model
 */
class ProjectCenter extends BaseModel {
	// 定义表名
	protected $name = 'shiyao_project_center';

	// 定义主键
	protected $pk = 'id';

	/**
	 * 追加字段
	 * @var array
	 */
	protected $append = ['status_text'];
	public function getStatusTextAttr($value, $data) {

		switch ($data['status']) {
		case 1:
			$type = '启用';
			break;
		case 2:
			$type = '关闭';
			break;

		default:
			$type = '其他';
			break;
		}
		return $type;
	}

	public function project() {
		return $this->hasOne('Project', 'project_id', 'project_id');
	}

	public function pi() {
		return $this->hasMany('Pi', 'center_id', 'id');
	}
	public function crc() {
		return $this->hasMany('Crc', 'center_id', 'id');
	}
	public function pm() {
		return $this->hasOne('app\\common\\model\\User', 'user_id', 'pm_id');
	}
	public function pm2() {
		return $this->hasOne('app\\common\\model\\User', 'user_id', 'pm_id_xiezhu');
	}
	/*
		*审批人
	*/
	public function pms() {
		return $this->hasMany('ProjectCenterPm', 'center_id', 'id');
	}

}
